import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
// 挂载请求头拦截器
axios.interceptors.request.use(config => {
  // console.log(config)
  // 在请求头中新增一个authorization字段值为token值
  config.headers.Authorization = window.sessionStorage.getItem('token')
  if (
    config.url.indexOf('survey') !== -1 ||
    config.url.indexOf('download') !== -1
  ) {
    config.baseURL = 'http://127.0.0.1:9000/'
  } else {
    config.baseURL = 'https://lianghj.top:8888/api/private/v1/'
  }
  return config
})
// axios.defaults.baseURL = 'https://lianghj.top:8888/api/private/v1/'
// axios.defaults.baseURL = 'http://127.0.0.1:9000/'
// 自定义命名
Vue.prototype.$http = axios
// 全局注册vue-table-with-tree-grid组件
Vue.component('tree-table', TreeTable)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
